package com.woniuxy.education.mapper;

import com.woniuxy.education.entity.Class;
import com.woniuxy.education.entity.dto.Tclass;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * @author author
 * @create 2021/4/7
 */
@Mapper
public interface ClassMapper {

   //班级信息查询
    @Select("select c.cname,t.subject,c.createTime,c.div_class,c.status,c.headTeacher," +
            "t.name,t.position  from Class c ,tea_class tc ,teacher t " +
            "where tc.c_id = c.id and t.id = tc.t_id and t.state != 2")
    List<Tclass> selectClassInfo();

    //未分配班主任班级信息查询
    @Select("select id,cname,status,headTeacher from class where headTeacher is null")
    List<Class> selectNoHeadTeacher();

    //未分班的班级信息查询
    @Select("select cname,createTime,div_class,status from class where status = 0")
    List<Class> noDivClass(@Param("page") int page, @Param("size") int size);
    //查询班级名称为cname的班级
    @Select("select * from class where cname = #{cname}")
    Class selectClassName(String cname);
    //创建班级
    @Insert("insert into class (cname,createTime,div_class) values (#{cname},#{createTime},#{div_class})")
    boolean createClass(@Param("cname") String cname,@Param("createTime") Date createTime,@Param("div_class") Date div_class);
    //查询与班级相关的教师id
    @Select("select t_id from tea_class where c_id = #{id}")
    List<Integer> findTeacher(int id);
}
